package com.trkj.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojos.Tbshift;
import com.trkj.service.HwcShiftService;
import com.trkj.vo.Result;

@Controller
public class HwcShiftController {
	
	@Autowired
	private HwcShiftService	shiftService;
	/**
	 * 添加新的班次
	 * @param shiftName
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	@RequestMapping("/hwc_addNewShift")
	public @ResponseBody	Result addShift(String shiftName,String startDate,String endDate){
		shiftService.addShift(shiftName, startDate, endDate);
		return new Result(true,"成功！");
	}
	
	/**
	 * 分页查询所有没有被废弃的班次
	 * @return
	 */
	@RequestMapping("/hwc_queryShift")
	public @ResponseBody	Map<String,Object> queryShift(int page,int rows){
		return shiftService.queryShift(page,rows);
	}
	/**
	 * 查询所有没有被废弃的班次（不分页）
	 * @return
	 */
	@RequestMapping("/hwc_queryAllShift")
	public @ResponseBody List<Tbshift> queryAllShift(){
		return shiftService.queryAllShift();
	}
	/**
	 * 修改班次信息
	 * @param shift
	 * @return
	 */
	@RequestMapping("/updateShift")
	public @ResponseBody Result updateShift(Tbshift shift){
		shiftService.updateShift(shift);
		return new Result(true,"修改成功");
	}
	
	/**
	 * 根据班次编号查询班次
	 * @param shiftNo
	 * @return
	 */
	public @ResponseBody Tbshift findShiftNoByShift(long shiftNo){
		return shiftService.findShiftNoByShift(shiftNo);
	}
	/**
	 * 删除班次
	 * @param list
	 * @return
	 */
	@RequestMapping("/delShift")
	public @ResponseBody Result delShift(Long[] list){
		shiftService.delShift(list);
		return new Result(true,"班次删除成功！");
	}
}
